package com.google.code.mamule.integration;

import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Response;

/**
 * Created with IntelliJ IDEA. User: borck_000 ; Date: 12/24/13 ; Time: 3:22 PM
 */
public class Endpoint {

  public static <ENTITY> ENTITY failIfNull(ENTITY it, String message, Object... args) {
    if (it == null) {
      Response resp = Response
          .status(Response.Status.NOT_FOUND)
          .entity(Message.error(message, args))
          .build();
      throw new WebApplicationException(resp);
    }
    return it;
  }

  private Endpoint() {
  }
}
